package com.study.demo.schduleTask;

import com.study.demo.dto.Info;
import com.study.demo.repository.InfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class Task1 {

    @Autowired
    private InfoRepository infoRepository;


    @Scheduled(cron = "*/5 * * * * ?")
    public void saveToDB() {
        Info info = new Info();
        info.setContent("aaa");
        info.setFlag(1);
        info.setDate(new Date());
        infoRepository.save(info);
    }
}
